package cn.edu.zafu.bigdata.Wym;

public class Wym_Cube {

    private double length;
    private double width;
    private double height;

    public Wym_Cube(double length,double width,double height){
        this.length=length;
        this.width=width;
        this.height=height;
    }//初始化

    public double getLength(){
        return length;
    }

    public double getWidth() {
        return width;
    }

    public double getHeight() {
        return height;
    }

    public boolean equals(Object obj){
        if (this==obj) return true;//判断是否为同一对象，如cube1.equals(cube1)则返回true
        if (obj == null || !(obj instanceof Wym_Cube)) return false;//判断是否obj是null，判断是否是Wym_Cube类型

        Wym_Cube other = (Wym_Cube) obj;//强制类型转换

        return Double.compare(this.length,other.length)==0 && Double.compare(this.width, other.width)==0 && Double.compare(this.height,other.height)==0;
    }

    public static void main(String[] args){
        Wym_Cube cube1=new Wym_Cube(3.0,4.0,5.0);
        Wym_Cube cube2=new Wym_Cube(4.0,4.0,4.0);
        Wym_Cube cube3=new Wym_Cube(3.0,4.0,5.0);

        System.out.println("cube1 equals cube2:"+cube1.equals(cube2));
        System.out.println("cube1 equals cube3:"+cube1.equals(cube3));
        System.out.println("cube2 equals cube3:"+cube2.equals(cube3));

    }
}
